import org.lwjgl.Sys;

import spaceinvaders.Game;

/**
 * The initial code is based on the FullscreenExample and
 *   spaceinvedaers from the lwjgl.org
 */

/**
 * 
 *
 */
public class SpaStaSwe {

	private static long m_lastFrame = 0;

	/** Game title */
	public static final String GAME_TITLE = "Space Station Sweeper";

	private static final Boolean m_bFULLSCREEN = true;


	/**
	 * Get the time in milliseconds From:
	 * http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_4_(Timing) The
	 * Sys.getTime() method is LWJGL's high resolution timer and will return
	 * time in 'ticks'. This value can be in any format (nanoseconds,
	 * microsecond, milliseconds, etc) whichever is deemed to be best on the
	 * platform. The Sys.getTimerResolution() method will return the number of
	 * 'ticks' in a second. When both these methods are used together it allows
	 * conversion to any required metric (including milliseconds). See the
	 * Javadoc for LWJGL Sys class for more information. To get milliseconds
	 * from Sys.getTime(), the 'ticks' are multiplied by 1000 so that the end
	 * result will be in milliseconds and then divide by the number of ticks in
	 * a second.
	 * 
	 * @return The system time in milliseconds
	 */
	public static long getTime() {
		return (Sys.getTime() * 1000) / Sys.getTimerResolution();
	}

	/**
	 * From: http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_4_(Timing)
	 * In many games an int value (usually called delta) is used to store the
	 * number of milliseconds that have passed since the last frame. This value
	 * can be used to move entities in the game in a frame independent way.
	 * Meaning that regardless of how fast or slow the fps is everything should
	 * move at a constant speed. This value is calculated by saving the time
	 * from the timer every frame and subtracting it from the time on the
	 * previous frame.
	 * 
	 * @return
	 */
	public static int getDelta() {
		long time = getTime();
		int delta = (int) (time - m_lastFrame);
		m_lastFrame = time;

		return delta;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// openGraphicsLibrary.initGL(); // init OpenGL
		// openGraphicsLibrary.getDelta(); // call once before loop to
		// initialise lastFrame
		// lastFPS = getTime(); // call before loop to initialise fps timer


		System.out.println("III main().");
		Boolean isApplication = true;
		Game game = new Game(m_bFULLSCREEN, GAME_TITLE, isApplication);
		game.execute();
		// Load the sprites, possibly a sprite class.
		// load the sounds, from a sound class?

	}

}
